package com.itheima.controller;

import com.itheima.constant.MessageConstant;
import com.itheima.entiity.Result;
import com.itheima.pojo.Setmeal;
import com.itheima.service.SetmealService;
//import org.apache.dubbo.config.annotation.Reference;
import com.alibaba.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/setmeal")
public class SetmealController {

    @Reference
    SetmealService setmealService;

    @RequestMapping("/getSetmeal")
    public Result getAllSetmeal(){
        try{
            List<Setmeal> setmealList = setmealService.findAll();
            return new Result(true,MessageConstant.QUERY_SETMEAL_SUCCESS,setmealList);
        }catch(Exception ex){
            ex.printStackTrace();
            return new Result(false, MessageConstant.QUERY_SETMEAL_FAIL);
        }

    }
    @RequestMapping("/findById1")
    public Result findById(Integer id){
        try{
           // Setmeal setmeal=  setmealService.findById(id);
            Setmeal setmeal=setmealService.findById1(id);
            return new Result(true,MessageConstant.QUERY_SETMEAL_SUCCESS,setmeal);
        }catch (Exception ex){
            ex.printStackTrace();
        }

        return new Result(false,MessageConstant.QUERY_SETMEAL_FAIL);

    }
}
